package monitormercado.apresentacao.comum;



import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;


public class PainelLog extends Composite {

	public PainelLog(Composite container, int estilo, Point tamanho) {
		super(container, SWT.NONE);
		painel = new Group(this, estilo);

		logArea = new StyledText(painel, SWT.BORDER);
		logArea.setBackground(new Color(getDisplay(), new RGB(255, 255, 255)));
		logArea.setLocation(0, 20);
		logArea.setSize(tamanho);
		logArea.setEditable(false);
		
		painel.pack();
	}

	public void printLog(String log) {
		if (logArea.getText() == null) {
			logArea.setText(log);
		} else {
			logArea.setText(logArea.getText() + "\n" + log);
		}
		painel.pack();
	}
	
	public void setTitulo(String titulo) {
		painel.setText(titulo);
	}
	
	public String getText() {
		return logArea.getText();
	}
	
	public void setText(String texto) {
		logArea.setText(texto);
	}
	
	private Group painel = null;
	private StyledText logArea = null;
}
